﻿using System;
using AutoMapper;

namespace ECommerce.Specs
{
    public static class AutoMapperTestHelper
    {
        public static void ShouldFormatValueAs<TInput>(this IValueFormatter formatter, TInput input, string expectedOutput)
        {
            var context = new ResolutionContext(null, input, typeof(TInput), typeof(string));

            string actualOutput = formatter.FormatValue(context);

            if (String.Compare(actualOutput, expectedOutput, StringComparison.Ordinal) != 0)
            {
                throw new AutoMapperOutputAssertionException(
                    String.Format("Expected IValueFormatter output: {0}. Actual output: {1}",
                    expectedOutput,
                    actualOutput));
            }
        }
    }

}
